package com.example.ivideo_2211a.activity

import android.os.Bundle
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.common.mvi.BaseViewActivity
import com.example.ivideo_2211a.R
import com.example.ivideo_2211a.databinding.ActivityMainBinding

import com.example.ivideo_2211a.fg.FYTFragment
import com.example.ivideo_2211a.fg.HomeFragment
import com.example.ivideo_2211a.fg.MineFragment
import com.example.ivideo_2211a.fg.ZBFragment
import com.google.android.material.bottomnavigation.BottomNavigationView
@Route(path = "/app/MainActivity")
class MainActivity : BaseViewActivity<ActivityMainBinding>() {
    override fun getLayoutId(): Int = R.layout.activity_main

    override fun setupViews() {
        val navHostFragment = supportFragmentManager.findFragmentById(R.id.fragmentContainerView) as NavHostFragment
        val navController = navHostFragment.navController
        binding.bottom.setupWithNavController(navController)
        // 拦截加号点击，跳转到CreateFragment
        binding.bottom.setOnItemSelectedListener { item ->
            if (item.itemId == R.id.add_bottom) {
                navController.navigate(R.id.createFragment)
                false // 不高亮加号
            } else {
                // 其它菜单正常切换
                navController.navigate(item.itemId)
                true
            }
        }
    }
}